package com.cryptooj.project.judge.codesandbox.impl;

import com.cryptooj.project.judge.codesandbox.CodeSandbox;
import com.cryptooj.project.judge.codesandbox.model.ExecuteCodeRequest;
import com.cryptooj.project.judge.codesandbox.model.ExecuteCodeResponse;
import com.cryptooj.project.judge.codesandbox.model.JudgeInfo;
import com.cryptooj.project.model.enums.JudgeInfoMessageEnum;
import com.cryptooj.project.model.enums.QuestionSubmitStatusEnum;

import java.util.List;

/**
 *  示例代码沙箱：仅用于跑通业务流程
 * */
public class ExampleCodeSandbox implements CodeSandbox {

    /**
     *  编译-执行代码
     * */
    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        List<String> inputList = executeCodeRequest.getInputList();
        ExecuteCodeResponse executeCodeResponse = new ExecuteCodeResponse();
        executeCodeResponse.setOutputList(inputList);
        executeCodeResponse.setMessage("测试示例代码沙箱");
        executeCodeResponse.setStatus(QuestionSubmitStatusEnum.SUCCESS.getValue());
        JudgeInfo judgeInfo = new JudgeInfo();
        judgeInfo.setMessage(JudgeInfoMessageEnum.ACCEPTED.getText());
        judgeInfo.setMemory(1024*10L);
        judgeInfo.setTime(1000*10L);
        executeCodeResponse.setJudgeInfo(judgeInfo);
        return executeCodeResponse;
    }
}
